package edu.example.house.serlvet;

import edu.example.bean.buildings;
import edu.example.house.dao.housemanageDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/searchBuilding")
public class BuildingSearchServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String field = request.getParameter("field");
        String value = request.getParameter("value");


        List<buildings> searchResults =new housemanageDao().search(field, value);


        request.setAttribute("searchResults", searchResults);


        request.getRequestDispatcher("/buildingmanage/searchResults.jsp").forward(request, response);
    }
}
